/**
 * 
 */
package array.passed2;

/**
我报个面经那么，snapchat，第一轮电话，从左上角打印到右下角
 */
public class PrinntMatrixByDiagonal {

	public void print(int[][] arr) {
		if (arr == null || arr.length == 0)
			return;
		
		int size = arr.length;
		for (int i = 0; i < size; i++) {
			for (int x = 0, y = i; x < size && y >= 0; x++, y--) {
				System.out.print(arr[x][y]);
			}
			System.out.println();
		}
		
		for (int i = 1; i < size; i++) {
			for (int x = i, y = size - 1; x < size && y >= 0; x++, y--) {
				System.out.print(arr[x][y]);
			}
			System.out.println();
		}
		
	}
	
	/**
	 * 
	 */
	public PrinntMatrixByDiagonal() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PrinntMatrixByDiagonal obj = new PrinntMatrixByDiagonal();
		int[][] arr = {
		                {1, 2, 3, 4},
		                {5, 6, 7, 8},
		                {9, 10, 11, 12},
		                {13, 14, 15, 16}
		              };
		obj.print(arr);
	}

}
